﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VipCo.Data;
using VipCo.Entities;

public partial class Controls_SlideShowControl : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            HienthiSlideshow();
        }
    }

    public string GetTieuDe(object Char)
    {
        string s = Char.ToString();
        return Common.ConvertToUnSign(s);
    }

    protected void HienthiSlideshow()
    {
        int totalRows = 0;
        string whereClause = "1=1";
        // Lay danh sach cac Slideshow
        TList<SlideShow> tlistSlideShows = DataRepository.SlideShowProvider.GetPaged(whereClause, "UuTien ASC", 0, 0, out totalRows);

        if (tlistSlideShows.Count > 0)
        {
            string sHtml = "";
            foreach (var slideShow in tlistSlideShows)
            {
                sHtml += "<div class=\"item\">";
                sHtml += "<img src=\"Upload/SlideShow/" + slideShow.AnhDaiDien + "\" alt= />";
                sHtml += "<div class=\"carousel-caption\">";
                sHtml += "<h1><a href=\"" + slideShow.LienKet + "\">" + slideShow.TieuDe + "</a></h1>";
                sHtml += "<p>" + Server.HtmlDecode(slideShow.TomTat) + "</p>";
                sHtml += "</div>";
                sHtml += "<div class=\"phan-tram-slide\"><span>" + slideShow.PhanTram + "%</span></div>";
                sHtml += "</div>";

                ltSlideshow.Text = sHtml;
            }
        }
    }
}